#include "factoryline.h"

int UNIQUE_OBJECT_ID = 1;

CFactoryObject::CFactoryObject()
{
  
  m_ID = UNIQUE_OBJECT_ID++;
  m_Tag = "";
  
}


CFactoryObject * CFactoryLine::Find( std::string tag )
{
 
  for( std::vector< CFactoryObject * >::iterator iter = m_pObjects.begin();
       iter != m_pObjects.end(); iter++ )
      {
      
		  if( ( *iter )->GetTag() == tag )
			  return ( *iter );
	
      }
      
  return NULL;
  
  
}

CFactoryObject * CFactoryLine::Find( int id )
{
 
  for( std::vector< CFactoryObject * >::iterator iter = m_pObjects.begin();
       iter != m_pObjects.end(); iter++ )
      {
      
		  if( ( *iter )->GetID() == id )
			  return ( *iter );
	
      }
      
  return NULL;
  
}

void CFactoryLine::Add( CFactoryObject * o )
{

  m_pObjects.push_back( o );

}

CFactoryObject * CFactoryLine_Map::Get( std::string id )
{

	return m_pObjects.at( id );
	
}

CFactoryObject * CFactoryLine_Map::Find( std::string tag )
{
 
  for( std::map< std::string, CFactoryObject * >::iterator iter = m_pObjects.begin();
       iter != m_pObjects.end(); iter++ )
      {
      
		  if( ( *iter ).second->GetTag() == tag )
			  return ( *iter ).second;
	
      }
      
  return NULL;
  
  
}

CFactoryObject * CFactoryLine_Map::Find( int id )
{
 
  for( std::map< std::string, CFactoryObject * >::iterator iter = m_pObjects.begin();
       iter != m_pObjects.end(); iter++ )
      {
      
		  if( ( *iter ).second->GetID() == id )
			  return ( *iter ).second;
	
      }
      
  return NULL;
  
}


void CFactoryLine_Map::Add( std::string name, CFactoryObject * o )
{

  m_pObjects.set( name, o );

}